home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 32 / Amiga Format AFCD32 (Nov 1998, Issue 117).iso / -seriously_amiga- / programming / e / newgui / src / plugins / pl_iconbutton.e < prev    next >
Text File  |  1998-08-10  |  4KB  |  100 lines

  1. /* 
  2.  *  Icon-Plug Version 2.0
  3.  * -====================-
  4.  * 
  5.  * Changes:
  6.  * --------
  7.  *
  8.  * 1.0: = First Release
  9.  *      - Drawed Image with DrawImage()
  10.  *
  11.  * 1.1: = Bugfix inside min_size (wrong height!)
  12.  *
  13.  * 1.2: = Experimental Version with GadTools-Button-Gadget
  14.  *      - Not working correct!
  15.  * 
  16.  * 1.3: = You could choose now the gadget (select-render)
  17.  * 
  18.  * 1.4: = Internal BugFix (Drawing the selected Image at wrong coordinates!)
  19.  * 
  20.  * 1.5: = Changed the Image-Plugin to Icon-Plugin 
  21.  *      - Uses now the Gadget-Structure of the diskobject (PTR)
  22.  *
  23.  * 1.6: = Added the Selectable-Feature
  24.  *
  25.  * 1.7: = Bugfix inside message_test(), now searching for the right mes.iadress
  26.  *
  27.  * 1.8: = Bugfix! Now the Icon is really selectable!
  28.  *      - added self.gad.gadgettype=GTYP_BOOLGADGET-Flag
  29.  *      - added self.gad.activation=GACT_RELVERIFY -Flag
  30.  *      - correcting the Position of the Image (x,y)
  31.  *      - correcting the size of the Image (width,height)
  32.  *
  33.  * 1.9: = Cosmetical changing
  34.  *      - changed the contructurs-name from create() to icon()
  35.  *
  36.  * 2.0: = First NewGUI-Release
  37.  *      - Rewrote the Plugin for NewGUI (Recompiling)
  38.  *      - added the ICON-Constant, makes your Gui-Description more readable!
  39.  *      - Added OPT OSVERSION = 37, the compilers says no longer "Module changed OPT-Direction" or so...(?)
  40.  */
  41.  
  42. OPT     MODULE
  43. OPT     OSVERSION = 37
  44.  
  45. MODULE    'newgui/newgui',
  46.     'intuition/intuition'
  47.  
  48. EXPORT  CONST   ICON = PLUGIN
  49.  
  50. EXPORT  OBJECT  icon OF plugin
  51.  sel                                            /* Ist das (Image auswählbar?                   */
  52. PRIVATE
  53.  win:PTR TO window                              /* PTR des Windows...                           */
  54.  gad:PTR TO gadget                              /* INITIALISIERTE (!) Gadget-Struktur...        */
  55. ENDOBJECT
  56.  
  57. PROC icon(gd:PTR TO gadget,sel)       OF icon
  58.  self.gad:=gd                                   /* Gadget (PTR) speichern...                    */
  59.   self.sel:=sel                                 /* Gadget auswählbar?                           */
  60.    self.gad.gadgetid:=0
  61.     self.gad.gadgettype:=GTYP_BOOLGADGET
  62.      self.gad.activation:=GACT_RELVERIFY
  63. ENDPROC
  64.  
  65. PROC will_resize()               OF icon IS 0 -> Nicht resizeable!
  66.  
  67. PROC min_size(x,y)               OF icon IS self.gad.width,self.gad.height
  68.  
  69. PROC render(a,x,y,xs,ys,win:PTR TO window)       OF icon 
  70.  DEF    gad=0:PTR TO gadget
  71.   gad:=self.gad
  72.    gad.leftedge:=x
  73.     gad.topedge:=y
  74.      gad.width:=xs
  75.       gad.height:=ys
  76.   IF self.win=NIL                               /* Wenn der Window-PTR nicht gesetzt ist!       */ 
  77.     AddGadget(win,gad,-1)                       /* Gadget ans Ende der Liste anhängen!          */
  78.    self.win:=win                                /* WindowPTR im Objekt speichern...             */
  79.   ENDIF
  80.    RefreshGadgets(gad,win,0)                    /* Gadget refreshen + zeichnen...               */
  81. ENDPROC TRUE
  82.  
  83. PROC message_test(msg:PTR TO intuimessage,win)   OF icon
  84.  DEF    class, gad:PTR TO gadget
  85.   IF self.sel=FALSE                             /* Wenn das Gadget nicht angewählt werden darf..*/
  86.    RETURN FALSE                                 /* Prozedur mit FALSE (keine Msg für uns!) verl.*/
  87.   ELSE                                          /* Wenn auswählbar!                             */
  88.    class:=msg.class                             /* Klasse (Art) festlegen                       */
  89.     SELECT class                                /* Wenn Button losgelassen wurde!               */
  90.      CASE       IDCMP_GADGETUP
  91.       gad:=msg.iaddress
  92.        IF gad=self.gad                          /* Wenn der Code = der ID                       */
  93.         RETURN TRUE                             /* Wahr (eine Msg für uns!) zurück!             */
  94.        ENDIF
  95.     ENDSELECT
  96.   ENDIF
  97. ENDPROC FALSE                                   /* Standart -> Keine Msg für uns!               */
  98.  
  99. PROC message_action(a,b,c,win)        OF icon IS TRUE
  100.